{
  "properties" : { },
  "id" : "a1c14a546b0443fc8f38c64b79b41e37",
  "script" : null,
  "groupId" : "15f14f8b44ad445095f0f89dca8fc895",
  "name" : "举报进度",
  "createTime" : null,
  "updateTime" : 1741279133831,
  "lock" : null,
  "createBy" : null,
  "updateBy" : "管理员",
  "path" : "jubao_get",
  "method" : "GET",
  "parameters" : [ ],
  "options" : [ ],
  "requestBody" : "",
  "headers" : [ ],
  "paths" : [ ],
  "responseBody" : "{\n    \"code\": 200,\n    \"msg\": \"success\",\n    \"data\": 0\n}",
  "description" : null,
  "requestBodyDefinition" : null,
  "responseBodyDefinition" : null
}
================================
// selenium
import org.openqa.selenium.OutputType
import org.openqa.selenium.By
import org.openqa.selenium.WebElement
import org.openqa.selenium.firefox.FirefoxOptions
import org.openqa.selenium.firefox.FirefoxProfile
import org.openqa.selenium.firefox.FirefoxDriver
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.Cookie
// baidu aip
import com.baidu.aip.ocr.AipOcr;
// 个人代码 工具类
import com.wiwf.model.manage.utils.SeleniumUtil;
// 其他
import org.ssssssss.magicapi.utils.IoUtils
import org.apache.commons.net.util.Base64
import org.json.JSONObject
import org.json.JSONArray
import java.io.File
import response
import http;
import log;

SeleniumUtil.quit();
FirefoxDriver driver = SeleniumUtil.getFoxDriver("D:/data/spider/file/geckodriver.exe");

var url = 'https://' + 'www.xxxxxxx.com/jbcx/'; // 地址
var jsOK = false;  // 是否解析成功
var words = ''; // 验证码
var cxm = '37FE4056D53C0FE0B427FAAA92D0FC0E'; //查询码
var type = 1;


var maxError = 10;  // 最大异常错误次数
while(jsOK == false){
    if(maxError < 0){
        break;
    }
    // 获取验证码
    driver.get(url);
    WebElement we = driver.findElement(By.xpath('//*[@id="app"]/div/div[3]/div[2]/form/div[3]/div/img'));
    var imguri = 'D:/tmpimg/'+now().getTime()+'.jpg';
    var rtmpFile = new File(imguri);
    IoUtils.write(rtmpFile, we.getScreenshotAs(OutputType.BYTES));

    // 解析验证码，调用 文字识别
    var APP_ID = "27063008"; var API_KEY = "74UmYpvc1AgxGDLRYpdgsRI2"; var SECRET_KEY = "yzdv1KLi6c2oYNHOuv7htT32UWqQB8lZ";
    AipOcr client = new AipOcr(APP_ID, API_KEY, SECRET_KEY);

    HashMap options = new HashMap();
    options.put("detect_direction", "true"); options.put("language_type", "ENG"); options.put("probability", "true");
    JSONArray array = client.basicGeneral(imguri, options).getJSONArray("words_result");

        // 识别符合
        if (array.length() > 0) {
            JSONObject jsonObject = array.getJSONObject(0);
            JSONObject probability = jsonObject.getJSONObject("probability");
            words = jsonObject.getString("words").replace(' ','');
            log.info("Probability: " + probability.toString());
            log.info("Words: " + words);

            if(words.length() == 4){
                jsOK = true;
            } else {
                rtmpFile.delete();
                continue;
            }

            // 自定选中举报类型 并 填写相关信息
            WebElement weSEL = driver.findElement(By.xpath('//*[@id="app"]/div/div[3]/div[2]/form/div[1]/div/div/div[1]/input'));
            weSEL.click();
            WebElement weSEL2 = driver.findElement(By.xpath('//html/body/div[5]/div[1]/div[1]/ul/li['+type+']'));
            weSEL2.click();
            WebElement weCXM = driver.findElement(By.xpath('//*[@id="app"]/div/div[3]/div[2]/form/div[2]/div/div/input'));
            weCXM.clear();
            weCXM.sendKeys(cxm);
            WebElement weYZM = driver.findElement(By.xpath('//*[@id="app"]/div/div[3]/div[2]/form/div[3]/div/div/input'));
            weYZM.sendKeys(words);
            // 提交
            WebElement weSub = driver.findElement(By.xpath('//*[@id="app"]/div/div[3]/div[2]/form/div[4]/div/button'));
            weSub.click();
            weAct = new Actions(driver); weAct.pause(1*1000); weAct.perform();

            // 检查弹出信息
            try{
                var msg = driver.findElement(By.xpath('//html/body/div[6]')).getText();
                if(msg.equals('暂无相关信息')){
                    log.info(msg);
                    // ..........
                    return 0
                }
            } catch(e) {
                log.info('err');
            }
            // 提交是否通过
            try {
                var resTxt = driver.findElement(By.xpath('//*[@id="app"]/div/div[3]/div[2]/div')).getText();
                return {'code': cxm, 'text': resTxt};
            } catch(e) {
                // 失败
                jsOK = false;
                maxError = maxError - 1;
            }

        } else {
            return 500;
        }
    
    weAct = new Actions(driver); weAct.pause(2*1000); weAct.perform();
}


return 0;